﻿using System;
using System.Text;
using System.Text.RegularExpressions;


namespace AAPL.BAL.Rules
{
    public static class RuleHelper
    {

        // IsValidEmail
        public static bool IsValidEmail(string email)
        {
            if (Regex.IsMatch(email, "\\b[A-Z0-9._%-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}\\b", RegexOptions.IgnoreCase)) { return true; }
            else { return false; }
        }


        // IsValidPassword
        public static bool IsValidPassword(string password)
        {
            if (string.IsNullOrEmpty(password.Trim())) { return false; }
            else if (password.Trim().Length < 6) { return false; }
            else { return true; }
        }


        // IsValidCity
        public static bool IsValidCity(string city)
        {
            if (string.IsNullOrEmpty(city.Trim())) { return false; }
            else { return true; }
        }


        // IsValidStateCode
        //public static bool IsValidStateCode(string stateCode)
        //{
        //    if (string.IsNullOrEmpty(stateCode.Trim())) { return false; }
        //    else if (!StateRepository.GetAll().Exists(n => n.StateCode == stateCode)) { return false; }
        //    else { return true; }
        //}


        // IsValidZipCode
        public static bool IsValidZipCode(int ZipCode)
        {
            // Placeholder, we should implement a check against a list 
            // of valid zip codes later.
            return true;
        }


        //// IsValidUSTimeZone
        //public static bool IsValidUSTimeZoneId(int timeZoneId)
        //{
        //    if (!TimeZoneRepository.GetAllUS().Exists(n => n.TimeZoneId == timeZoneId)) { return false; }
        //    else { return true; }
        //}


        //// IsValidImTypeId
        //public static bool IsValidImTypeId(int imTypeId)
        //{
        //    if (!ImTypeRepository.GetAll().Exists(n => n.ImId == imTypeId)) { return false; }
        //    else { return true; }
        //}
    }
}
